local sishuizhufeng = fk.CreateSkill {
  name = "inker_sishuizhufeng",
  max_turn_use_time = 2,
}

sishuizhufeng:addEffect(fk.AfterCardsMove, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(sishuizhufeng.name) then return false end
    local discardor = {}
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile and move.moveReason == fk.ReasonDiscard and move.from and not player:inMyAttackRange(move.from) then
        table.insertIfNeed(discardor, move.from)
      end
    end

    if #discardor > 0 then
      event:setSkillData(self, "inker_sishuizhufeng_discardor", discardor)
      return true
    end
  end,
  on_trigger = function(self, event, target, player, data)
    event:setSkillData(self, "cancel_cost", false)

    local dat = event:getSkillData(self, "inker_sishuizhufeng_discardor")
    for _, to in ipairs(dat) do
      if to:isAlive() then
        event:setSkillData(self, "inker_sishuizhufeng_to", to)
        self:doCost(event, target, player, data)
      end
    end

    event:setSkillData(self, "cancel_cost", false)
  end,
  on_cost = function(self, event, target, player, data)
    local to = event:getSkillData(self, "inker_sishuizhufeng_to")
    if not to or not to:isAlive() then return false end
    if player.room:askToSkillInvoke(player, {
      skill_name = sishuizhufeng.name,
      prompt = "#inker_sishuizhufeng-invoke:" .. to.id,
    }) then
      event:setCostData(self, { tos = { to } })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    if not to or not to:isAlive() then return end

    local judge = {
      who = player,
      reason = sishuizhufeng.name,
      pattern = {
        [".|2~9|spade"] = "bad",
        ["else"] = "good"
      },
    }

    room:judge(judge)
    if judge:matchPattern() then
      room:drawCards(to, 1, sishuizhufeng.name)
    end
  end
}, { check_skill_limit = true })

Fk:loadTranslationTable{
  ["inker_sishuizhufeng"] = "似水铸锋",
  [":inker_sishuizhufeng"] = "每回合限两次，当你攻击范围外的角色弃置牌后，你可以进行判定。若结果不为♠2~9，其摸一张牌。",

  ["#inker_sishuizhufeng-invoke"] = "似水铸锋：你可以进行判定。若结果不为♠2~9，%src 摸一张牌",

  ["$inker_sishuizhufeng1"] = "但不该这样，被无视者的故事我来替他们讲。",
  ["$inker_sishuizhufeng2"] = "侦察，策划，布局……然后推进。",
}

return sishuizhufeng